package cn.yangsen.simplebeanmanager.bean.html;

import lombok.Getter;
import lombok.Setter;
import cn.yangsen.simplebeanmanager.bean.html.itfc.Cleanable;
import cn.yangsen.simplebeanmanager.bean.html.itfc.SubmitAble;
import cn.yangsen.simplebeanmanager.tool.HtmlTool;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter;

@XStreamAlias("textarea")
@XStreamConverter(value = ToAttributedValueConverter.class, strings =
	{ "content" })
public class Textarea extends Element implements Cleanable,SubmitAble
{
	@Getter
	@Setter
	@XStreamAsAttribute
	private String name;

	@Getter
	private String content = "";

	@Getter
	@Setter
	@XStreamAsAttribute
	private Integer rows;

	@Getter
	@Setter
	@XStreamAsAttribute
	private Integer cols = 80;
	
	@XStreamAsAttribute
	private String disabled;
	
	public void setContent(String content)
	{
		this.content = HtmlTool.预留字段转字符实体(content);
	}

	@Override
	public void clean()
	{
		content = "";
	}
	
	public void setDisabled(boolean disabled)
	{
		if (disabled)
		{
			this.disabled = "disabled";
		}
		else
		{
			this.disabled = null;
		}
	}
}
